package com.xintoucloud.pbs.dao.impl;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xintoucloud.pbs.dao.PartyPaymentDao;
import com.xintoucloud.pbs.entity.PartyPayment;
@Repository
public class PartyPaymentDaoImpl implements PartyPaymentDao{
	
	@Autowired
	private SessionFactory sessionFactory;
	@Override
	public Serializable save(PartyPayment partypayment) {
		return sessionFactory.getCurrentSession().save(partypayment);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<PartyPayment> list() {
		return sessionFactory.getCurrentSession().createQuery("from PartyPayment").list();
	}
	@Override
	public void update(PartyPayment partypayment) {
		int partyPaymentId = partypayment.getPartyPaymentId();
		System.out.println("=============================="+partyPaymentId);
		BigDecimal amountPayable = partypayment.getAmountPayable();
		BigDecimal payAmount = partypayment.getAmountPayable();
		Date limitTime = partypayment.getLimitedPaymentTime();
		Date paymentTime = partypayment.getPaymentTime();
		sessionFactory.getCurrentSession().createQuery("update PartyPayment p set p.amountPayable='"+amountPayable+"'"
				+ ",p.payAmount='"+payAmount+"',p.limitedPaymentTime='"+limitTime+"',p.paymentTime='"+paymentTime+"' where p.partyPaymentId="+partyPaymentId+"").executeUpdate();
	}

}
